package com.fdc_project.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;


@Component
public class DateHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("cusInsertTime", LocalDateTime.now(),metaObject);
        this.setFieldValByName("cusUpdateTime", LocalDateTime.now(),metaObject);
        this.setFieldValByName("proInsertTime",LocalDateTime.now(),metaObject);
        this.setFieldValByName("proEndTime",LocalDateTime.now(),metaObject);
        this.setFieldValByName("deleted",0,metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("cusUpdateTime", LocalDateTime.now(),metaObject);
        this.setFieldValByName("proEndTime", LocalDateTime.now(),metaObject);
    }
}
